/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
typedef struct ListNode ListNode;
struct ListNode* reverseList(struct ListNode* head)
{
    ListNode* newhead = NULL, * pcur = head;
    while (pcur)
    {
        ListNode* next = pcur->next;
        pcur->next = newhead;
        newhead = pcur;
        pcur = next;
    }
    return newhead;
}